/**
 *  iBizSys 5.0 机器人生产代码（不要直接修改当前代码）
 *  http://www.ibizsys.net
 */
package com.sa.litetwo.srv.card.service;


import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import net.ibizsys.paas.exception.ErrorException;
import net.ibizsys.paas.core.PluginActionResult;
import net.ibizsys.paas.core.IDataEntity;
import net.ibizsys.paas.core.IDEDataSetFetchContext;
import net.ibizsys.paas.db.DBCallResult;
import net.ibizsys.paas.db.DBFetchResult;
import net.ibizsys.paas.db.IProcParam;
import net.ibizsys.paas.util.StringHelper;
import net.ibizsys.paas.util.StringBuilderEx;
import net.ibizsys.paas.core.Errors;
import net.ibizsys.paas.core.ActionContext;
import net.ibizsys.paas.data.DataObject;
import net.ibizsys.paas.service.ServiceGlobal;
import net.ibizsys.paas.entity.IEntity;
import net.ibizsys.paas.demodel.IDataEntityModel;
import net.ibizsys.paas.demodel.DEModelGlobal;
import net.ibizsys.paas.demodel.IDELogicModel;
import net.ibizsys.paas.dao.DAOGlobal;
import net.ibizsys.paas.web.WebContext;
import net.ibizsys.paas.service.IService;
import net.ibizsys.paas.util.DataTypeHelper;
import net.ibizsys.paas.util.KeyValueHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.ibizsys.paas.db.SelectCond;
import net.ibizsys.paas.service.IServiceWork;
import net.ibizsys.paas.service.IServicePlugin;
import net.ibizsys.paas.service.ITransaction;
import net.ibizsys.paas.dao.IDAO;
import net.ibizsys.paas.service.CloneSession;
import net.ibizsys.paas.service.ServiceBase;
import net.ibizsys.paas.entity.EntityFieldError;
import net.ibizsys.paas.entity.EntityError;
import java.sql.Timestamp;
import net.ibizsys.paas.util.DefaultValueHelper;
import javax.annotation.PostConstruct;
import net.ibizsys.paas.service.IDataContextParam;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;



import com.sa.litetwo.srv.card.entity.GG_ATTACH;
import com.sa.litetwo.srv.card.dao.GG_ATTACHDAO;
import com.sa.litetwo.srv.card.demodel.GG_ATTACHDEModel;


/**
 * 实体[GG_ATTACH] 服务对象基类
 */
@Component
public class GG_ATTACHService extends com.sa.litetwo.srv.liteTwoSysServiceBase<GG_ATTACH>{
	private static final Log log = LogFactory.getLog(GG_ATTACHService.class);
	/**
	 * 实体数据集合[DEFAULT]标识
	 */
   public final static String DATASET_DEFAULT = "DEFAULT";


   public GG_ATTACHService (){
        super();
       
   }

    /**
     * 获取实体[GG_ATTACH]服务对象
     * @param sessionFactory
     * @return
     * @throws Exception
     */   
    public static GG_ATTACHService getInstance() throws Exception{
    	return getInstance(null);
    }
    
    /**
     * 获取实体[GG_ATTACH]服务对象
     * @param sessionFactory
     * @return
     * @throws Exception
     */
    public static GG_ATTACHService getInstance(SessionFactory sessionFactory) throws Exception{
    	return (GG_ATTACHService)ServiceGlobal.getService(GG_ATTACHService.class, sessionFactory);
    }
       
	/**
	 * Spring注册后执行构造处理
	 * @throws Exception
	 */
   @PostConstruct  
   public void postConstruct() throws Exception{    
	   ServiceGlobal.registerService(getServiceId(), this);
   }     
   	
   	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#getServiceId()
	 */
   @Override
   protected String getServiceId()
   {
	   return "com.sa.litetwo.srv.card.service.GG_ATTACHService";
   }

    private GG_ATTACHDEModel gG_ATTACHDEModel;
    /**
     * 获取实体[GG_ATTACH]模型对象
     */
    public  GG_ATTACHDEModel getGG_ATTACHDEModel(){
      	if(this.gG_ATTACHDEModel==null){
                try
                {
                     this.gG_ATTACHDEModel = (GG_ATTACHDEModel)DEModelGlobal.getDEModel("com.sa.litetwo.srv.card.demodel.GG_ATTACHDEModel");
                }
                catch(Exception ex)
                {
                }
            }
           return this.gG_ATTACHDEModel;
      }
    
    /* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#getDEModel()
	 */
	@Override
   public  IDataEntityModel getDEModel() {
	   return this.getGG_ATTACHDEModel();
   }
 

   private GG_ATTACHDAO gG_ATTACHDAO;

   /**
    * 获取实体[GG_ATTACH]数据操作对象
    */
     public  GG_ATTACHDAO getGG_ATTACHDAO() {
        if(this.gG_ATTACHDAO==null){
                try
                {
                     this.gG_ATTACHDAO= (GG_ATTACHDAO)DAOGlobal.getDAO("com.sa.litetwo.srv.card.dao.GG_ATTACHDAO",this.getSessionFactory());
                }
                catch(Exception ex)
                {
                }
            }
           return this.gG_ATTACHDAO;
    }
   
    /* (non-Javadoc)
 	 * @see net.ibizsys.paas.service.IService#getDAO()
 	 */
 	@Override
    public  IDAO getDAO() {
        return this.getGG_ATTACHDAO();
    }
 	
	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onfetchDataSet(java.lang.String, net.ibizsys.paas.core.IDEDataSetFetchContext)
	 */
    @Override
	protected DBFetchResult onfetchDataSet(String strDataSetName,IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception
	{
              if(StringHelper.compare(strDataSetName,DATASET_DEFAULT,true)==0){
                   return this.fetchDefault(iDEDataSetFetchContext);
              }
              return super.onfetchDataSet(strDataSetName,iDEDataSetFetchContext);
	}

    /**
     * 获取数据集合
   	 * @param strDataSetName
   	 * @param iDEDataSetFetchContext
   	 * @return
   	 * @throws Exception
   	 */
    @Override
   	protected DBFetchResult onfetchDataSetTemp(String strDataSetName,IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception
   	{
         if(StringHelper.compare(strDataSetName,DATASET_DEFAULT,true)==0){
                return this.fetchTempDefault(iDEDataSetFetchContext);
         }
         return super.onfetchDataSetTemp(strDataSetName,iDEDataSetFetchContext);
   	}
	
	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onExecuteAction(java.lang.String, net.ibizsys.paas.entity.IEntity)
	 */
   	@Override
	protected  void onExecuteAction(String strAction,IEntity entity) throws Exception
	{
            super.onExecuteAction(strAction,entity);
	}

    /**
	 * 获取数据集合[DEFAULT]
	 * @param iDEDataSetFetchContext
	 * @return
	 * @throws Exception
	 */
public DBFetchResult fetchDefault(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception{

    DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_DEFAULT,false);
   // dbFetchResult.getDataSet().cacheDataRow();
   // session.close();
    return dbFetchResult;
}

        /**
	 * 获取数据集合[DEFAULT]（临时数据模型）
	 * @param iDEDataSetFetchContext
	 * @return
	 * @throws Exception
	 */
public DBFetchResult fetchTempDefault(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception{

    DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_DEFAULT,true);
    return dbFetchResult;
}





	
	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onFillParentInfo(net.ibizsys.paas.entity.IEntity, java.lang.String, java.lang.String, java.lang.String)
	 */
    @Override
    protected void onFillParentInfo(GG_ATTACH et,String strParentType,String strTypeParam,String strParentKey) throws Exception
    {
         //关系类型 : DER1N ,主实体 :GG_CARD / 简历信息卡
         if (((StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER1N, true) == 0)
        		 ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER1N, true) == 0)
        		 ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER11, true) == 0)
        		 ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER11, true) == 0)) 
            && (StringHelper.compare(strTypeParam, "DER1N_GG_ATTACH_GG_CARD_CARDID", true)==0))
         {
             IService iService= ServiceGlobal.getService("com.sa.litetwo.srv.card.service.GG_CARDService",this.getSessionFactory());
              com.sa.litetwo.srv.card.entity.GG_CARD parentEntity = ( com.sa.litetwo.srv.card.entity.GG_CARD)iService.getDEModel().createEntity();
              parentEntity.set(com.sa.litetwo.srv.card.entity.GG_CARD.FIELD_GG_CARDID,DataTypeHelper.parse(25,strParentKey));
              if(strParentKey.indexOf(ServiceBase.TEMPKEY) == 0)
                  iService.getTemp(parentEntity);
              else
                  iService.get(parentEntity);
              this.onFillParentInfo_CARD(et,parentEntity );
              return;
         }
         super.onFillParentInfo(et,strParentType,strTypeParam,strParentKey);
    }
    
    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onSyncDER1NData(java.lang.String, java.lang.String, java.lang.String)
     */
    @Override
	protected String onSyncDER1NData(String strDER1NId, String strParentKey, String strDatas) throws Exception
	{
		return super.onSyncDER1NData( strDER1NId,  strParentKey,  strDatas);
	}


     /**
     * 填充数据的父数据信息[简历信息卡]
     * @param et 当前数据对象
     * @param parentEntity 父数据对象
     * @throws Exception
     */
    protected void onFillParentInfo_CARD(GG_ATTACH et,com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
            et.setCARDID(parentEntity.getGG_CARDId());
    }
    



	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onFillEntityFullInfo(net.ibizsys.paas.entity.IEntity, boolean)
	 */
    @Override
     protected void onFillEntityFullInfo(GG_ATTACH et, boolean bCreate) throws Exception
    {
		//填充新建默认值
    	if(bCreate)
    	{
    	}
        super.onFillEntityFullInfo(et, bCreate);

        //填充物理化外键相关属性
         //关系类型 : DER1N ,主实体 :GG_CARD / 简历信息卡
         onFillEntityFullInfo_CARD(et, bCreate);
    }

     /**
     * 填充实体的数据信息 简历信息卡
     * @param et
     * @param bCreate 是否建立
     * @throws Exception
     */
     protected void onFillEntityFullInfo_CARD(GG_ATTACH et, boolean bCreate) throws Exception
    {
    }

	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onWriteBackParent(net.ibizsys.paas.entity.IEntity, boolean)
	 */
	@Override
	protected void onWriteBackParent(GG_ATTACH et, boolean bCreate) throws Exception
	{
		super.onWriteBackParent(et, bCreate);
	}
	



    /**
     * 通过关系[简历信息卡]父数据查询数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public java.util.ArrayList<GG_ATTACH> selectByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
        return selectByCARD(parentEntity,"");
    }
     /**
      * 通过关系[简历信息卡]父数据查询数据
      * @param parentEntity 父数据
      * @param strOrderInfo 排序信息
      * @throws Exception
      */
    public java.util.ArrayList<GG_ATTACH> selectByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity,String strOrderInfo) throws Exception
    {
         SelectCond selectCond = new SelectCond();
         selectCond.setConditon(GG_ATTACH.FIELD_CARDID, parentEntity.getGG_CARDId());
         selectCond.setOrderInfo(strOrderInfo);
         onFillSelectByCARDCond(selectCond);
         return this.select(selectCond);
    }

    /**
     * 填充关系[简历信息卡]父数据查询附加条件
     * @param selectCond 查询条件对象
     * @throws Exception
     */
    protected void onFillSelectByCARDCond(SelectCond selectCond) throws Exception
    {

    }
   /**
     * 通过关系[简历信息卡]父数据查询数据（临时数据模式）
     * @param parentEntity 父数据
     * @throws Exception
     */
    public java.util.ArrayList<GG_ATTACH> selectTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
        return selectTempByCARD( parentEntity,"");
    }
     /**
      * 通过关系[简历信息卡]父数据查询数据（临时数据模式）
      * @param parentEntity 父数据
      * @param strOrderInfo 排序信息
      * @throws Exception
      */
    public java.util.ArrayList<GG_ATTACH> selectTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity,String strOrderInfo) throws Exception
    {
         SelectCond selectCond = new SelectCond();
	 selectCond.setConditon(GG_ATTACH.FIELD_CARDID, parentEntity.getGG_CARDId());
         selectCond.setOrderInfo(strOrderInfo);
	 onFillSelectTempByCARDCond(selectCond);
	 return this.selectTemp(selectCond);
    }

    /**
     * 填充关系[简历信息卡]父数据查询附加条件（临时数据模式）
     * @param selectCond 查询条件对象
     * @throws Exception
     */
    protected void onFillSelectTempByCARDCond(SelectCond selectCond) throws Exception
    {

    }



    
    /**
     * 判断是否能够通过关系[简历信息卡]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void testRemoveByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
    }

    
    /**
     * 通过关系[简历信息卡]重置数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void resetCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
    	java.util.ArrayList<GG_ATTACH> list =  this.selectByCARD(parentEntity);
    	for(GG_ATTACH item:list)
    	{
    		GG_ATTACH item2 = (GG_ATTACH)getDEModel().createEntity();
    		item2.setGG_ATTACHId(item.getGG_ATTACHId());
    		item2.setCARDID(null);
    		this.update(item2);
    	}
    }

	/**
     * 判断是否能够通过关系[简历信息卡]删除数据（临时数据模式）
     * @param parentEntity 父数据
	 * @throws Exception
	 */
	public void resetTempCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
	{
		java.util.ArrayList<GG_ATTACH> list =  this.selectTempByCARD(parentEntity);
		for(GG_ATTACH item:list)
		{
			GG_ATTACH item2 = (GG_ATTACH)getDEModel().createEntity();
			item2.setGG_ATTACHId(item.getGG_ATTACHId());
			item2.setCARDID(null);
			this.updateTemp(item2);
		}
	}
    
    /**
     * 通过关系[简历信息卡]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void removeByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
         final com.sa.litetwo.srv.card.entity.GG_CARD parentEntity2 = parentEntity;
	 this.doServiceWork(new IServiceWork()
	 {
	    @Override
	    public void execute(ITransaction iTransaction) throws Exception
	    {
                onBeforeRemoveByCARD(parentEntity2);
                internalRemoveByCARD(parentEntity2);
                onAfterRemoveByCARD(parentEntity2);
	    }
	});
    }

    /**
     * 通过关系[简历信息卡]删除数据之前调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onBeforeRemoveByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {

    }
  
     /**
     * 内部删除数据，通过关系[简历信息卡]
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void internalRemoveByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
          java.util.ArrayList<GG_ATTACH> removeList = selectByCARD(parentEntity);
          onBeforeRemoveByCARD(parentEntity,removeList );
           
          // 执行删除
	  for (GG_ATTACH item : removeList )
	  {
		remove(item );
	  }
          onAfterRemoveByCARD(parentEntity,removeList );
    }
    
    /**
     * 通过关系[简历信息卡]删除数据之后调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onAfterRemoveByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {

    }

    /**
     * 通过关系[简历信息卡]删除数据之前调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单 
     * @throws Exception
     */
    protected void onBeforeRemoveByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity,java.util.ArrayList<GG_ATTACH> removeList) throws Exception
    {

    }

    /**
     * 通过关系[简历信息卡]删除数据之后调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单 
     * @throws Exception
     */
    protected void onAfterRemoveByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity,java.util.ArrayList<GG_ATTACH> removeList) throws Exception
    {

    }

	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onBeforeRemove(net.ibizsys.paas.entity.IEntity)
	 */
    @Override
    protected void onBeforeRemove(GG_ATTACH et) throws Exception
    {
		super.onBeforeRemove(et);
    }


     /**
     * 通过关系[简历信息卡]删除数据（临时数据模式）
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void removeTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
         final com.sa.litetwo.srv.card.entity.GG_CARD parentEntity2 = parentEntity;
	 this.doServiceWork(new IServiceWork()
	 {
	    @Override
	    public void execute(ITransaction iTransaction) throws Exception
	    {
                onBeforeRemoveTempByCARD(parentEntity2);
                internalRemoveTempByCARD(parentEntity2);
                onAfterRemoveTempByCARD(parentEntity2);
	    }
	});
    }

    /**
     * 通过关系[简历信息卡]删除数据之前调用（临时数据模式）
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onBeforeRemoveTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {

    }
  
     /**
     * 通过关系[简历信息卡]删除数据之后调用（临时数据模式）
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void internalRemoveTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {
          java.util.ArrayList<GG_ATTACH> removeList = selectTempByCARD(parentEntity);
          onBeforeRemoveTempByCARD(parentEntity,removeList );
           
          //逐个执行删除
		  for (GG_ATTACH item : removeList )
		  {
			  removeTemp(item );
		  }
          onAfterRemoveTempByCARD(parentEntity,removeList );
    }
    
    /**
     * 通过关系[简历信息卡]删除数据之后调用（临时数据模式）
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onAfterRemoveTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity) throws Exception
    {

    }

    /**
     * 通过关系[简历信息卡]删除数据之前调用（临时数据模式）
     * @param parentEntity 父数据
     * @param removeList 删除数据清单
     * @throws Exception
     */
    protected void onBeforeRemoveTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity,java.util.ArrayList<GG_ATTACH> removeList) throws Exception
    {

    }

    /**
     * 通过关系[简历信息卡]删除数据之后调用（临时数据模式）
     * @param parentEntity 父数据
     * @param removeList 删除数据清单
     * @throws Exception
     */
    protected void onAfterRemoveTempByCARD(com.sa.litetwo.srv.card.entity.GG_CARD parentEntity,java.util.ArrayList<GG_ATTACH> removeList) throws Exception
    {

    }



     /**
      * 替换父数据信息
      * @param et
      * @throws Exception
      */
     @Override
     protected void replaceParentInfo(GG_ATTACH et,CloneSession cloneSession) throws Exception
     {
    	 super.replaceParentInfo(et, cloneSession);
        //循环所有的从关系，判断有误替换
        if(et.getCARDID()!=null)
        {
            IEntity entity = cloneSession.getEntity("GG_CARD",et.getCARDID());
            if(entity !=null)
            {
            	onFillParentInfo_CARD(et,(com.sa.litetwo.srv.card.entity.GG_CARD) entity);
            }
        } 
     }

	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onRemoveEntityUncopyValues(net.ibizsys.paas.entity.IEntity, boolean)
	 */
	@Override
	protected void onRemoveEntityUncopyValues(GG_ATTACH et, boolean bTempMode) throws Exception
	{
		super.onRemoveEntityUncopyValues(et,  bTempMode);
	}

	
    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onCheckEntity(boolean, net.ibizsys.paas.entity.IEntity, boolean, boolean, net.ibizsys.paas.entity.EntityError)
     */
	@Override
	protected void onCheckEntity(boolean bBaseMode,GG_ATTACH  et, boolean bCreate, boolean bTempMode,EntityError entityError) throws Exception
	{
		EntityFieldError entityFieldError = null;
          //检查属性 附件标识
          entityFieldError = onCheckField_GG_ATTACHId( bBaseMode,  et,  bCreate,  bTempMode);
          if(entityFieldError!=null){entityError.register(entityFieldError);}
          //检查属性 附件名称
          entityFieldError = onCheckField_GG_ATTACHName( bBaseMode,  et,  bCreate,  bTempMode);
          if(entityFieldError!=null){entityError.register(entityFieldError);}
          //检查属性 人员
          entityFieldError = onCheckField_CARDID( bBaseMode,  et,  bCreate,  bTempMode);
          if(entityFieldError!=null){entityError.register(entityFieldError);}
          //检查属性 附件类型
          entityFieldError = onCheckField_FJLX( bBaseMode,  et,  bCreate,  bTempMode);
          if(entityFieldError!=null){entityError.register(entityFieldError);}
          //检查属性 链接
          entityFieldError = onCheckField_LJ( bBaseMode,  et,  bCreate,  bTempMode);
          if(entityFieldError!=null){entityError.register(entityFieldError);}
          //检查属性 附件
          entityFieldError = onCheckField_FJ( bBaseMode,  et,  bCreate,  bTempMode);
          if(entityFieldError!=null){entityError.register(entityFieldError);}
          //检查属性 备注
          entityFieldError = onCheckField_BZ( bBaseMode,  et,  bCreate,  bTempMode);
          if(entityFieldError!=null){entityError.register(entityFieldError);}
		super.onCheckEntity(bBaseMode,et,  bCreate,bTempMode,entityError);
	}
	
	
	/**
	 * 获取属性[GG_ATTACHId]值错误
	 * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据
	 * @param bTempMode 是否为临时数据模式
	 * @throws Exception
	 */
	protected EntityFieldError onCheckField_GG_ATTACHId(boolean bBaseMode,GG_ATTACH et, boolean bCreate, boolean bTempMode) throws Exception
	{
		//判断是否有值	
		if(!et.isGG_ATTACHIdDirty())
			return null;
		
		String value = et.getGG_ATTACHId();
		if(bBaseMode)
		{
			if(bCreate)
			{
		        if(StringHelper.isNullOrEmpty(value))
		        {
		        	EntityFieldError entityFieldError = new EntityFieldError();
		        	entityFieldError.setFieldName(GG_ATTACH.FIELD_GG_ATTACHID);
		        	entityFieldError.setErrorType(EntityFieldError.ERROR_EMPTY);
		        	return entityFieldError;
		        }
			}
			
			String strRuleInfo  = null;
			//检查值规则[默认规则]
			strRuleInfo =onTestValueRule_GG_ATTACHId_Default( et,  bCreate,  bTempMode);
			if(!StringHelper.isNullOrEmpty(strRuleInfo))
            {
           	 		EntityFieldError entityFieldError = new EntityFieldError();
           	 		entityFieldError.setFieldName(GG_ATTACH.FIELD_GG_ATTACHID);
           	 		entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
		         	entityFieldError.setErrorInfo(strRuleInfo);
		         	return entityFieldError;
            }
		}
		else
		{
		}
		return null;
	}
	

	/**
	 * 获取属性[GG_ATTACHName]值错误
	 * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据
	 * @param bTempMode 是否为临时数据模式
	 * @throws Exception
	 */
	protected EntityFieldError onCheckField_GG_ATTACHName(boolean bBaseMode,GG_ATTACH et, boolean bCreate, boolean bTempMode) throws Exception
	{
		//判断是否有值	
		if(!et.isGG_ATTACHNameDirty())
			return null;
		
		String value = et.getGG_ATTACHName();
		if(bBaseMode)
		{
			if(bCreate)
			{
			}
			
			String strRuleInfo  = null;
			//检查值规则[默认规则]
			strRuleInfo =onTestValueRule_GG_ATTACHName_Default( et,  bCreate,  bTempMode);
			if(!StringHelper.isNullOrEmpty(strRuleInfo))
            {
           	 		EntityFieldError entityFieldError = new EntityFieldError();
           	 		entityFieldError.setFieldName(GG_ATTACH.FIELD_GG_ATTACHNAME);
           	 		entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
		         	entityFieldError.setErrorInfo(strRuleInfo);
		         	return entityFieldError;
            }
		}
		else
		{
		}
		return null;
	}
	

	/**
	 * 获取属性[CARDID]值错误
	 * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据
	 * @param bTempMode 是否为临时数据模式
	 * @throws Exception
	 */
	protected EntityFieldError onCheckField_CARDID(boolean bBaseMode,GG_ATTACH et, boolean bCreate, boolean bTempMode) throws Exception
	{
		//判断是否有值	
		if(!et.isCARDIDDirty())
			return null;
		
		String value = et.getCARDID();
		if(bBaseMode)
		{
			if(bCreate)
			{
			}
			
			String strRuleInfo  = null;
			//检查值规则[默认规则]
			strRuleInfo =onTestValueRule_CARDID_Default( et,  bCreate,  bTempMode);
			if(!StringHelper.isNullOrEmpty(strRuleInfo))
            {
           	 		EntityFieldError entityFieldError = new EntityFieldError();
           	 		entityFieldError.setFieldName(GG_ATTACH.FIELD_CARDID);
           	 		entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
		         	entityFieldError.setErrorInfo(strRuleInfo);
		         	return entityFieldError;
            }
		}
		else
		{
		}
		return null;
	}
	

	/**
	 * 获取属性[FJLX]值错误
	 * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据
	 * @param bTempMode 是否为临时数据模式
	 * @throws Exception
	 */
	protected EntityFieldError onCheckField_FJLX(boolean bBaseMode,GG_ATTACH et, boolean bCreate, boolean bTempMode) throws Exception
	{
		//判断是否有值	
		if(!et.isFJLXDirty())
			return null;
		
		String value = et.getFJLX();
		if(bBaseMode)
		{
			if(bCreate)
			{
			}
			
			String strRuleInfo  = null;
			//检查值规则[默认规则]
			strRuleInfo =onTestValueRule_FJLX_Default( et,  bCreate,  bTempMode);
			if(!StringHelper.isNullOrEmpty(strRuleInfo))
            {
           	 		EntityFieldError entityFieldError = new EntityFieldError();
           	 		entityFieldError.setFieldName(GG_ATTACH.FIELD_FJLX);
           	 		entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
		         	entityFieldError.setErrorInfo(strRuleInfo);
		         	return entityFieldError;
            }
		}
		else
		{
		}
		return null;
	}
	

	/**
	 * 获取属性[LJ]值错误
	 * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据
	 * @param bTempMode 是否为临时数据模式
	 * @throws Exception
	 */
	protected EntityFieldError onCheckField_LJ(boolean bBaseMode,GG_ATTACH et, boolean bCreate, boolean bTempMode) throws Exception
	{
		//判断是否有值	
		if(!et.isLJDirty())
			return null;
		
		String value = et.getLJ();
		if(bBaseMode)
		{
			if(bCreate)
			{
			}
			
			String strRuleInfo  = null;
			//检查值规则[默认规则]
			strRuleInfo =onTestValueRule_LJ_Default( et,  bCreate,  bTempMode);
			if(!StringHelper.isNullOrEmpty(strRuleInfo))
            {
           	 		EntityFieldError entityFieldError = new EntityFieldError();
           	 		entityFieldError.setFieldName(GG_ATTACH.FIELD_LJ);
           	 		entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
		         	entityFieldError.setErrorInfo(strRuleInfo);
		         	return entityFieldError;
            }
		}
		else
		{
		}
		return null;
	}
	

	/**
	 * 获取属性[FJ]值错误
	 * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据
	 * @param bTempMode 是否为临时数据模式
	 * @throws Exception
	 */
	protected EntityFieldError onCheckField_FJ(boolean bBaseMode,GG_ATTACH et, boolean bCreate, boolean bTempMode) throws Exception
	{
		//判断是否有值	
		if(!et.isFJDirty())
			return null;
		
		String value = et.getFJ();
		if(bBaseMode)
		{
			if(bCreate)
			{
			}
			
			String strRuleInfo  = null;
			//检查值规则[默认规则]
			strRuleInfo =onTestValueRule_FJ_Default( et,  bCreate,  bTempMode);
			if(!StringHelper.isNullOrEmpty(strRuleInfo))
            {
           	 		EntityFieldError entityFieldError = new EntityFieldError();
           	 		entityFieldError.setFieldName(GG_ATTACH.FIELD_FJ);
           	 		entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
		         	entityFieldError.setErrorInfo(strRuleInfo);
		         	return entityFieldError;
            }
		}
		else
		{
		}
		return null;
	}
	

	/**
	 * 获取属性[BZ]值错误
	 * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据
	 * @param bTempMode 是否为临时数据模式
	 * @throws Exception
	 */
	protected EntityFieldError onCheckField_BZ(boolean bBaseMode,GG_ATTACH et, boolean bCreate, boolean bTempMode) throws Exception
	{
		//判断是否有值	
		if(!et.isBZDirty())
			return null;
		
		String value = et.getBZ();
		if(bBaseMode)
		{
			if(bCreate)
			{
			}
			
			String strRuleInfo  = null;
			//检查值规则[默认规则]
			strRuleInfo =onTestValueRule_BZ_Default( et,  bCreate,  bTempMode);
			if(!StringHelper.isNullOrEmpty(strRuleInfo))
            {
           	 		EntityFieldError entityFieldError = new EntityFieldError();
           	 		entityFieldError.setFieldName(GG_ATTACH.FIELD_BZ);
           	 		entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
		         	entityFieldError.setErrorInfo(strRuleInfo);
		         	return entityFieldError;
            }
		}
		else
		{
		}
		return null;
	}
	

	

	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onSyncEntity(net.ibizsys.paas.entity.IEntity, boolean)
	 */
	@Override
	protected void onSyncEntity(GG_ATTACH et, boolean bRemove) throws Exception
	{
		super.onSyncEntity( et,  bRemove);
	}


	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onSyncIndexEntities(net.ibizsys.paas.entity.IEntity, boolean)
	 */
	@Override
	protected void onSyncIndexEntities(GG_ATTACH et,boolean bRemove) throws Exception
	{
		super.onSyncIndexEntities(et,bRemove);
	}


	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#getDataContextValue(net.ibizsys.paas.entity.IEntity, java.lang.String, net.ibizsys.paas.service.IDataContextParam)
	 */
	@Override
	public Object getDataContextValue(GG_ATTACH et,String strField,IDataContextParam iDataContextParam)throws Exception
	{
		Object objValue = null;
		if(iDataContextParam!=null)
		{
		}
		
		objValue = super.getDataContextValue(et,strField,iDataContextParam);
		if(objValue!=null)
			return objValue;

		IEntity cARD =et.getCARD();
		if(cARD!=null)
		{
			if(cARD.contains(strField))
			{
				return cARD.get(strField);
			}
		}
		return null;
	}

	
	
	/* (non-Javadoc)
	 * @see net.ibizsys.paas.service.ServiceBase#onTestValueRule(java.lang.String, java.lang.String, net.ibizsys.paas.entity.IEntity, boolean, boolean)
	 */
	@Override
	protected String onTestValueRule(String strDEFieldName,String strRule,IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_LJ,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_LJ_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_GG_ATTACHNAME,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_GG_ATTACHName_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_GG_ATTACHID,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_GG_ATTACHId_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_CREATEMAN,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_CreateMan_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_UPDATEDATE,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_UpdateDate_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_UPDATEMAN,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_UpdateMan_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_BZ,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_BZ_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_FJ,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_FJ_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_FJLX,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_FJLX_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_CREATEDATE,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_CreateDate_Default(et,bCreate,bTempMode);
		if((StringHelper.compare(strDEFieldName,GG_ATTACH.FIELD_CARDID,true)==0)
				&&(StringHelper.compare(strRule,"DEFAULT",true)==0))
			return onTestValueRule_CARDID_Default(et,bCreate,bTempMode);
	
		return super.onTestValueRule( strDEFieldName, strRule, et,bCreate, bTempMode);
	}

	/**
	 * 判断值规则[链接][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_LJ_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("LJ", et, bTempMode,null,false,1000,true,"内容长度必须小于等于[1000]")))
				return null;
			return "内容长度必须小于等于[1000]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[附件名称][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_GG_ATTACHName_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("GG_ATTACHNAME", et, bTempMode,null,false,200,true,"内容长度必须小于等于[200]")))
				return null;
			return "内容长度必须小于等于[200]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[附件标识][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_GG_ATTACHId_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("GG_ATTACHID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
				return null;
			return "内容长度必须小于等于[100]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[建立人][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_CreateMan_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("CREATEMAN", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
				return null;
			return "内容长度必须小于等于[60]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[更新时间][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_UpdateDate_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		return null;
	}
	
	/**
	 * 判断值规则[更新人][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_UpdateMan_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("UPDATEMAN", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
				return null;
			return "内容长度必须小于等于[60]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[备注][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_BZ_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("BZ", et, bTempMode,null,false,1000,true,"内容长度必须小于等于[1000]")))
				return null;
			return "内容长度必须小于等于[1000]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[附件][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_FJ_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("FJ", et, bTempMode,null,false,2000,true,"内容长度必须小于等于[2000]")))
				return null;
			return "内容长度必须小于等于[2000]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[附件类型][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_FJLX_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("FJLX", et, bTempMode,null,false,10,true,"内容长度必须小于等于[10]")))
				return null;
			return "内容长度必须小于等于[10]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	
	/**
	 * 判断值规则[建立时间][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_CreateDate_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		return null;
	}
	
	/**
	 * 判断值规则[人员][默认规则]
	 * @param et 当前数据对象
	 * @param bCreate 是否为新建数据模式
	 * @param bTempMode 是否为临时数据模式
	 * @return
	 * @throws Exception
	 */
	protected String onTestValueRule_CARDID_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception
	{
		try
		{
			if((checkFieldStringLengthRule("CARDID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
				return null;
			return "内容长度必须小于等于[100]";
		}
		catch(Exception ex)
		{
			return ex.getMessage();
		}
	}
	


/* (non-Javadoc)
 * @see net.ibizsys.paas.service.ServiceBase#onMergeChild(java.lang.String, java.lang.String, net.ibizsys.paas.entity.IEntity)
 */
@Override
protected boolean onMergeChild(String strChildType, String strTypeParam, GG_ATTACH et) throws Exception{
	boolean bRet = false;
	if(super.onMergeChild( strChildType, strTypeParam,  et))
		bRet = true;
	return bRet;
}



/**
 * 更新父数据
 * @param et
 * @throws Exception
 */
@Override
protected void onUpdateParent(GG_ATTACH et)throws Exception{
	super.onUpdateParent(et);
}


}